<template>

    <div class="m-style have-nav">
        <blockIndexNavBar :title="'人事调动列表'"></blockIndexNavBar>
        <van-row>
            <van-col span="16">
                <van-search
                    v-model="u_name"
                    placeholder="请输入调动人名称"
                    @search="onSearch"
                >
                </van-search>
            </van-col>
            <van-col span="8" class="search-btn">
                <van-button type="primary" size="small" @click="onSearch">搜索</van-button>
            </van-col>
        </van-row>

        <m_pageList
            ref="pageList"
            :url="url"
            :cols="cols"
            :list-cond="listCond"
        >
            <template v-slot="scope">
                <strong>{{ scope.row.transfer_effective_date }}</strong>
            </template>
        </m_pageList>

<!--        <van-pull-refresh v-model="refreshing" @refresh="onRefresh">-->
<!--            <van-list-->
<!--                v-model="loading"-->
<!--                :finished="finished"-->
<!--                finished-text="没有更多了"-->
<!--                @load="getData"-->
<!--            >-->
<!--                <lee-card v-for="item in dataList" :key="item._id">-->
<!--                    <van-row>-->
<!--                        <van-col span="12">单位员工</van-col>-->
<!--                        <van-col span="12">{{ item.true_name }}</van-col>-->
<!--                    </van-row>-->
<!--                    <van-row>-->
<!--                        <van-col span="12">调动类型</van-col>-->
<!--                        <van-col span="12">{{ item.transfer_type_name }}</van-col>-->
<!--                    </van-row>-->
<!--                    <van-row>-->
<!--                        <van-col span="12">调动前部门</van-col>-->
<!--                        <van-col span="12">{{ item.before_dep }}</van-col>-->
<!--                    </van-row>-->
<!--                    <van-row>-->
<!--                        <van-col span="12">调动后部门</van-col>-->
<!--                        <van-col span="12">{{ item.transfer_dep.dep_name }}</van-col>-->
<!--                    </van-row>-->
<!--                    <van-row>-->
<!--                        <van-col span="12">申请时间</van-col>-->
<!--                        <van-col span="12">{{ tabformatDate(item.transfer_date) }}</van-col>-->
<!--                    </van-row>-->
<!--                    <van-row>-->
<!--                        <van-col span="12">调动生效时间</van-col>-->
<!--                        <van-col span="12">{{ tabformatDate(item.transfer_effective_date) }}</van-col>-->
<!--                    </van-row>-->
<!--                    -->
<!--                </lee-card>-->
<!--            </van-list>-->
<!--        </van-pull-refresh>-->
    </div>
</template>

<script>
import {Config} from "@/config/formDataOptions";
import blockIndexNavBar from "@/components/blockIndexNavBar";
import LeeCard from "@/uitl/card";
import {API_URL} from "@/config/urlInfo";
import m_pageList from "@/uitl/m_pageList";

export default {
    name: "transferList",
    components: {
        LeeCard,
        blockIndexNavBar,
        m_pageList
    },
    data() {
        return {
            url: API_URL.transferList,
            cols: {
                show: [
                    {title: '调动类型', field: 'transfer_type_name'},
                    {title: '调动前部门', field: 'before_dep'},
                    {title: '调动后部门', field: 'dep_name'},
                    {title: '申请时间', field: 'transfer_date'},
                    {title: '调动生效时间', field: 'transfer_effective_date'},
                ],
                // hide: [
                //
                // ]
            },
            u_name: "",
            listCond: {u_name: this.u_name}

        };
    },
    mounted() {
        // this.getData()
    },
    methods: {
        // 点击按钮
        handleIcons(router) {
            console.log('router', router)
            this.$router.push({path: "/mobile/offices/claim/articleClaim"})
        },
        tabformatDate(item) {
            let data = item
            if (data == null || data === '') {
                return ""
            }
            let dt = new Date(data)
            return dt.getFullYear() + '-' + (dt.getMonth() + 1) + '-' + dt.getDate()
        },
        onSearch() {
            this.getData()
        },
        onRefresh() {
            // 清空列表数据
            this.finished = false;

            // 重新加载数据
            // 将 loading 设置为 true，表示处于加载状态
            this.loading = true;
            this.getData();
        },

        getData() {
            // Config.getDatas("/hr/api/transfer/list", {data: {u_name: this.u_name}}, (res) => {
            Config.getDatas(API_URL.hrTransfer, {data: {u_name: this.u_name}}, (res) => {
                this.dataList = res.data
                this.loading = false;
                this.refreshing = false;
                if (this.dataList.length == 0 || this.dataList.length == res.totalRow) {
                    this.finished = true;
                } else {
                    this.finished = false;
                }
            }, this)
        }
    }
}
</script>

<style scoped lang="less">
.search-btn {
    .van-button {
        width: 48%;
        margin-right: 1%;
    }

    background: #fff;
    text-align: center;
    padding: 11px 0;
}

.list-btn {
    .van-button {
        width: 45%;
        margin-right: 2%;
        float: right;
    }
}

.wt-card {
    margin: 0.4rem;
    background: #fff;
    overflow: hidden;
    border-radius: 0.3rem;
    padding: 0.4rem;
    box-shadow: 0 0 0.2rem #ccc;
    border-bottom: 0.1rem solid #ccc;
}


.icons-warp {
    border-radius: 25px;

    .float-icon-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        position: relative;
        width: 50px;
        height: 50px;

        img {
            width: 25px;
            height: 25px;
            margin-bottom: 3px;
        }

        span {
            font-size: 9px;
            color: #666666;
        }
    }
}

</style>